#include <iostream>
#include <stack>
using namespace std;

const int kMaxN = 2e5 + 10;
const int kMaxA = 1e9;

int ans[kMaxN], a[kMaxN];
int l[kMaxN], r[kMaxN];

void GetAns(int n) {
  stack<int> s;

  a[0] = 0;
  s.push(0);
  for (int i = 1; i <= n; i++) {
    r[i] = n + 1;
    for (; a[s.top()] >= a[i]; s.pop()) {
      r[s.top()] = i;
    }
    l[i] = s.top();
    s.push(i);
  }
  for (int i = 1; i <= n; i++) {
    ans[r[i] - l[i] - 1] = max(ans[r[i] - l[i] - 1], a[i]);
  }
  for (int i = n - 1; i >= 1; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  GetAns(n);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  return 0;
}